/* 构造签名 */
type SomeObject = any;
type SomConstructor = {
  new (s: string): SomeObject;
}

function fn(ctor: SomConstructor) {
  return new ctor("hello");
}

fn(Date)



// 一些对象，比如 Date 对象，可以直接调用，也可以使用 new 操作符调用，而你可以将调用签名和构造签名合并在一起
interface CallOrConstruct {
  (n?: number): string;
  new (s: string): Date;
}

function fn1(ctor: CallOrConstruct) {
  // Passing an argument of type `number` to `ctor` matches it against
  // the first definition in the `CallOrConstruct` interface.
  console.log(ctor(10));

  // Similarly, passing an argument of type `string` to `ctor` matches it
  // against the second definition in the `CallOrConstruct` interface.
  console.log(new ctor("10"));
}

fn1(Date);